<template>
  <view class="c">
    <button @click="openBluetoothAdapter">openBluetoothAdapter</button>
    <button @click="startBluetoothDevicesDiscovery">startBluetoothDevicesDiscovery</button>
    <button @click="onBluetoothDeviceFound">onBluetoothDeviceFound</button>
    <button @click="stopBluetoothDevicesDiscovery">stopBluetoothDevicesDiscovery</button>
  </view>
</template>

<script>
export default {
  methods: {
    openBluetoothAdapter () {
      uni.openBluetoothAdapter({
        success: e => {
          console.log('openBluetoothAdapter success', e)
        },
        fail: e => {
          console.log('openBluetoothAdapter fail', e)
        }
      })
    },
    startBluetoothDevicesDiscovery () {
      uni.startBluetoothDevicesDiscovery({
        success: e => {
          console.log('startBluetoothDevicesDiscovery success', e)
        },
        fail: e => {
          console.log('startBluetoothDevicesDiscovery fail', e)
        }
      })
    },
    onBluetoothDeviceFound () {
      const date = Date.now()
      uni.onBluetoothDeviceFound(devices => {
        console.log('onBluetoothDeviceFound ' + date, devices)
      })
      console.log('onBluetoothDeviceFound success')
    },
    stopBluetoothDevicesDiscovery () {
      uni.stopBluetoothDevicesDiscovery({
        success: e => {
          console.log('stopBluetoothDevicesDiscovery success', e)
        },
        fail: e => {
          console.log('stopBluetoothDevicesDiscovery fail', e)
        }
      })
    }
  }
}
</script>

<style>
</style>